package me.spring.cloud.common.components.rpc.response.header;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author luffy
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CommonRespHeader<C> implements RespHeader<C> {

    private static final long serialVersionUID = 4119303775128147534L;
    /**
     * 响应码
     */
    private C code;

    /**
     * 响应消息
     */
    private String message;

    /**
     * 用于跟踪链路的全局id
     */
    private String chainId;

    /**
     * 时间戳
     */
    private String timestamp;

    public CommonRespHeader(C code, String message) {
        this.code = code;
        this.message = message;
        this.timestamp = String.valueOf(System.currentTimeMillis());
    }

    public CommonRespHeader(C code, String message,String chainId) {
        this.code = code;
        this.message = message;
        this.chainId = chainId;
        this.timestamp = String.valueOf(System.currentTimeMillis());
    }
}
